<?php

class Mod_Math extends CI_Model
{
	public function getAnwser(){
		$id = $this->uri->segment(3,0);
		$this->db->select('*');
		$this->db->from('tbl_answer');
		$this->db->where('question_id',$id);
		$this->db->limit(1);
		return $this->db->get();
	}

	public function getAllmath($start, $num, $keeping){
	     $this->db->select('*');
	     $this->db->select('tbl_subject.id AS Ids');
	     $this->db->from('tbl_subject');
	     $this->db->join('tbl_class', 'tbl_class.id = tbl_subject.class_id');
	     $this->db->join('tbl_answer', 'tbl_answer.question_id = tbl_subject.id');
	     $this->db->where('tbl_subject.deleted_at', NULL);
	     $this->db->where('tbl_subject.class_id',$keeping);
	     $this->db->order_by('tbl_subject.updated_at', 'DESC');
		 $this->db->limit($num, $start);
         $query = $this->db->get();
      return $query;
	}
    public function getMathNum($keeping){
    $objDb = $this->getMath($keeping);
    $query = $objDb->num_rows();
    return $query;
    }
    public function getMath($keeping){
	     $this->db->select('*');
	     $this->db->from('tbl_subject');
	     $this->db->join('tbl_class', 'tbl_class.id = tbl_subject.class_id');
	     $this->db->join('tbl_answer', 'tbl_answer.question_id = tbl_subject.id');
	     $this->db->where('tbl_subject.deleted_at', NULL);
	     $this->db->where('tbl_subject.class_id',$keeping);
	     $this->db->order_by('tbl_subject.updated_at', 'DESC');
	     $query  = $this->db->get();
      return $query;
	}
  

}